package converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import score.Status;

/**
 *
 * @author Thorsten Ludwig
 */
@FacesConverter(value="statusConverter")
public class StatusConverter implements Converter {

    
    @Override
    public Object getAsObject(FacesContext fc, UIComponent uic, String string) {
        if (string.equalsIgnoreCase("Bearbeitet")) 
            return Status.EDITED;
        else if (string.equalsIgnoreCase("Entschuldigt"))
            return Status.EXCUSED;
        else if (string.equalsIgnoreCase("Nicht bearbeitet"))
            return Status.NOT_EDITED;        
        else 
            return Status.NOT_INSERTED;
    }

    @Override
    public String getAsString(FacesContext fc, UIComponent uic, Object o) {
        if (o == Status.EDITED)
            return "Bearbeitet";
        else if (o == Status.EXCUSED)
            return "Entschuldigt";
        else if (o == Status.NOT_EDITED)
            return "Nicht bearbeitet";
        else 
            return "Nicht Eingetragen";
    }
    
}